#include "address_ui.h"

AddressUI::AddressUI(QWidget *parent)
    : QWidget(parent)
{
    setupUi(); // Initialize the UI
}

void AddressUI::setupUi()
{
    this->setFixedSize(1680, 930);

    // Disable maximize and minimize buttons
    this->setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
    this->setAttribute(Qt::WA_StyledBackground, true);
    this->setWindowTitle(tr("地址管理"));
    this->setWindowIcon(QIcon(QString::fromUtf8(":/icon/logo.png")));
    this->setStyleSheet("background-color: #FFFFFF");

    mainLayout = new QVBoxLayout(this);
    mainLayout->setAlignment(Qt::AlignTop);
    scrollArea = new QScrollArea;
    scrollArea->setWidgetResizable(true);

    QWidget *scrollWidget = new QWidget;
    scrollWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    gridLayout = new QGridLayout(scrollWidget);
    gridLayout->setAlignment(Qt::AlignTop);
    gridLayout->setVerticalSpacing(0);

    addAddressButton = new QPushButton("添加地址");
    addAddressButton->setStyleSheet("QPushButton { background-color: lightblue; }");

    int row = 0;
    QLabel *nameLabel = new QLabel("收件人：");
    QLabel *phoneLabel = new QLabel("手机号：");
    QLabel *areaLabel = new QLabel("姓名：");
    QLabel *detailLabel = new QLabel("详细地址：");
    QLabel *defaultLabel = new QLabel("设置默认地址");
    QLabel *manageLabel = new QLabel("管理地址");

    QString styleSheet = "QLabel { font-size: 14px; font-weight: bold; }";
    nameLabel->setStyleSheet(styleSheet);
    phoneLabel->setStyleSheet(styleSheet);
    areaLabel->setStyleSheet(styleSheet);
    detailLabel->setStyleSheet(styleSheet);
    defaultLabel->setStyleSheet(styleSheet);
    manageLabel->setStyleSheet(styleSheet);

    gridLayout->addWidget(nameLabel, row, 0);
    gridLayout->addWidget(phoneLabel, row, 1);
    gridLayout->addWidget(areaLabel, row, 2);
    gridLayout->addWidget(detailLabel, row, 3);
    gridLayout->addWidget(defaultLabel, row, 4);
    gridLayout->addWidget(manageLabel, row, 5);
    gridLayout->addWidget(addAddressButton, row, 6);

    scrollArea->setWidget(scrollWidget);
    mainLayout->addWidget(scrollArea);
}
AddressUI::~AddressUI() {}
